package com.koron.order.cockpit.controller;

import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.cockpit.service.YcCockpitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 驾驶舱
 *
 */
@Api(tags = "驾驶舱接口")
@RequestMapping("/cockpit")
@RestController
public class YcCockpitController {


    @Autowired
    private YcCockpitService ycCockpitService;

    public String getCurrDs(){
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation("缺陷工单")
    @GetMapping("/getDefect")
    public Response getDefectTypeAndCountByDate(@RequestParam String date){

        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"getDefectTypeAndCountByDate",Response.class,date);
    }


    @ApiOperation("巡视管理")
    @GetMapping("/getPatrol")
    public Response getPatrolCountByDate(@RequestParam String date){

        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"getPatrolCountByDate",Response.class,date);
    }

    @ApiOperation("工单总数量")
    @GetMapping("/sumOrder")
    public Response sumOrder(){
        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"sumOrderTotal",Response.class);
    }


    @ApiOperation("两票总数量")
    @GetMapping("/sumTicket")
    public Response sumTicket(){
        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"sumTicketTotal",Response.class);
    }

    @ApiOperation("设备状态")
    @GetMapping("/equipment")
    public Response getEquipmentStatus(PageQuery pageQuery){
        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"getEquipmentStatus",Response.class,pageQuery);
    }

    @ApiOperation("合格率-消缺率")
    @GetMapping("getDefectRate")
    public Response getDefectRate(String date){
        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"getDefectRate",Response.class,date);
    }

    @ApiOperation("合格率-消缺及时率")
    @GetMapping("getDefectInTimeRate")
    public Response getDefectInTimeRate(String date){
        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"getDefectInTimeRate",Response.class,date);
    }

    @ApiOperation("工单抽查合格率")
    @GetMapping("getOrderCheckPassRate")
    public Response getOrderCheckPassRate(String date){
        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"getOrderCheckPassRate",Response.class,date);
    }

    @ApiOperation("两票抽查合格率")
    @GetMapping("getTicketCheckPassRate")
    public Response getTicketCheckPassRate(String date){
        return ADOConnection.runTask(getCurrDs(),ycCockpitService,"getTicketCheckPassRate",Response.class,date);
    }
}
